/**
* Oxide
*
* Copyright (c) 2011 Dinosaur Kick Pty Ltd, All rights reserved.
*
* This source code is made available under the "Modified BSD" licensing arrangement.
* See license.txt for details.
*/
// ----------------------------------------------------------------------------

bool lex_string(void)
{
	assert(*m_cursor == '\'' || *m_cursor == '"');
	setup_token(TOK_STRING);
	char_type quote = m_cursor.get();
	char_type ch;
	bool escaped = false;

	while (m_cursor)
	{
		ch = m_cursor.get();

		if (escaped)
		{
			escaped = false;

			switch (ch)
			{
				case 'r':
					m_token.content += '\r';
					break;

				case 'n':
					m_token.content += '\n';
					break;

				case 't':
					m_token.content += '\t';
					break;

				default:
					m_token.content += '\\';

				case '\\':
				case '\'':
				case '"':
					m_token.content += ch;
					break;
			}
		}
		else
		{
			switch (ch)
			{
				case '\\':
					escaped = true;
					break;

				case '\'':
				case '"':
					if (ch == quote)
					{
						return true;
					}

				default:
					m_token.content += ch;
			}
		}
	}

	return false;
}

// ----------------------------------------------------------------------------
